import request from "@/api/request";
import { type Result, type DeepRequired } from "../../interface";
import { type AxiosRequestConfig } from "axios";

/**
 * 上传分片
 * /upload/upload/chunk
 */
export function postUploadUploadChunk(params: PostUploadUploadChunkParams, input?: PostUploadUploadChunkInput, config?: AxiosRequestConfig) {
    const paramsInput = {
        md5: params.md5,
        index: params.index,
        chunkTotal: params.chunkTotal,
        fileSize: params.fileSize,
        fileName: params.fileName,
        chunkSize: params.chunkSize,
    };
    return request.post<DeepRequired<Result>>(`/upload/upload/chunk`, input, {
        params: paramsInput,
        ...config,
    });
}

export interface PostUploadUploadChunkParams {
    md5: string;
    index: number;
    chunkTotal: number;
    fileSize: number;
    fileName: string;
    chunkSize: number;
}

export interface PostUploadUploadChunkInput {
    chunk: File;
}
